package com.company.project.builder.wx.outxml;

import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xsk
 */
public class NewsBuilder {

    public WxMpXmlOutMessage build(List<WxMpXmlOutNewsMessage.Item> articles , WxMpXmlMessage wxMessage) {

        me.chanjar.weixin.mp.builder.outxml.NewsBuilder nb  = WxMpXmlOutMessage.NEWS()
                .articles(articles)
                .fromUser(wxMessage.getToUser())
                .toUser(wxMessage.getFromUser());

        WxMpXmlOutNewsMessage m = nb.build();

        return m;
    }

    private void demo()
    {
        List<WxMpXmlOutNewsMessage.Item> articles = new ArrayList<>();

        WxMpXmlOutNewsMessage.Item itemOne = new WxMpXmlOutNewsMessage.Item();
        itemOne.setTitle("hi how are you");
        itemOne.setDescription("this is a demo demo");
        itemOne.setPicUrl("https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1510307158&di=258b895c1f6840f2b2af3802f6493b66&src=http://imgsrc.baidu.com/imgad/pic/item/9213b07eca806538025ec1349ddda144ad348264.jpg");
        itemOne.setUrl("https://jingyan.baidu.com/article/a3f121e4d3f752fc9052bb90.html");

        WxMpXmlOutNewsMessage.Item itemTwo = new WxMpXmlOutNewsMessage.Item();
        itemTwo.setTitle("hi how aldfjlakflk you");
        itemTwo.setDescription("this is asdkfkaslkf demo demo");
        itemTwo.setPicUrl("https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1510307158&di=258b895c1f6840f2b2af3802f6493b66&src=http://imgsrc.baidu.com/imgad/pic/item/9213b07eca806538025ec1349ddda144ad348264.jpg");
        itemTwo.setUrl("https://jingyan.baidu.com/article/a3f121e4d3f752fc9052bb90.html");

        articles.add(itemOne);
        articles.add(itemTwo);
    }

}
